home *** CD-ROM | disk | FTP | other *** search
/ SGI Performance Co-Pilot 1.3 / SGI Performance Co-Pilot 1.3.iso / dist / dist6.4 / pcp.idb / usr / share / catman / u_man / cat1 / pmgenmap.z / pmgenmap
Text File  |  1997-04-03  |  8KB  |  265 lines

  1.  
  2.  
  3.  
  4. PPPPMMMMGGGGEEEENNNNMMMMAAAAPPPP((((1111))))                                                        PPPPMMMMGGGGEEEENNNNMMMMAAAAPPPP((((1111))))
  5.  
  6.  
  7.  
  8. NNNNAAAAMMMMEEEE
  9.      ppppmmmmggggeeeennnnmmmmaaaapppp - generate C code to simplify handling of performance metrics
  10.  
  11. SSSSYYYYNNNNOOOOPPPPSSSSIIIISSSS
  12.      ppppmmmmggggeeeennnnmmmmaaaapppp [_i_n_f_i_l_e]
  13.  
  14. DDDDEEEESSSSCCCCRRRRIIIIPPPPTTTTIIIIOOOONNNN
  15.      Given one or more lists of metric names in _i_n_f_i_l_e or on standard input,
  16.      ppppmmmmggggeeeennnnmmmmaaaapppp generates C declarations and ccccpppppppp(1) macros suitable for use
  17.      acrosss the Performance Metrics Programming Interface (PMAPI) on standard
  18.      output.
  19.  
  20.      The declarations produced by ppppmmmmggggeeeennnnmmmmaaaapppp simplify the coding for client
  21.      applications using the PMAPI.
  22.  
  23.      The input should consist of one or more lists of metric names of the form
  24.  
  25.           listname {
  26.               metricname1 symbolname1
  27.               metricname2 symbolname2
  28.               ...
  29.           }
  30.  
  31.      which will generate C and ccccpppppppp(1) declarations of the form
  32.  
  33.           char *listname[] = {
  34.           #define symbolname1 0
  35.               "metricname1",
  36.           #define symbolname2 1
  37.               "metricname2",
  38.               ...
  39.           };
  40.  
  41.      The array declarations produced are suitable as parameters to
  42.      ppppmmmmLLLLooooooookkkkuuuuppppNNNNaaaammmmeeee(3) and the ####ddddeeeeffffiiiinnnneeeed constants may be used to index the _v_s_e_ts
  43.      in the _p_m_R_e_s_u_l_t structure returned by a ppppmmmmFFFFeeeettttcccchhhh(3) call.
  44.  
  45.      Obviously, _l_i_s_t_n_a_m_e must conform to the C identifier naming rules, each
  46.      _s_y_m_b_o_l_n_a_m_e must confrom to the ccccpppppppp(1) macro naming rules, and each
  47.      _m_e_t_r_i_c_n_a_m_e is expected to be a valid performance metrics name (see
  48.      ppppmmmmnnnnssss(4) for more details).
  49.  
  50.      The input may include sssshhhh-style comment lines, i.e. with a `####' as the
  51.      first non-blank character of a line, and these are translated on output
  52.      to either single line or multi-line C comments in the K&R style.  For
  53.      example, the input:
  54.  
  55.  
  56.           # leading block of multi-line comments
  57.           # RCS: $Revision: 2.3 $
  58.           # initialization group
  59.           foo {
  60.  
  61.  
  62.  
  63.                                                                         PPPPaaaaggggeeee 1111
  64.  
  65.  
  66.  
  67.  
  68.  
  69.  
  70. PPPPMMMMGGGGEEEENNNNMMMMAAAAPPPP((((1111))))                                                        PPPPMMMMGGGGEEEENNNNMMMMAAAAPPPP((((1111))))
  71.  
  72.  
  73.  
  74.                   a.b.c   ONE
  75.                   d.e.f.g TWO
  76.                   # embedded block of multi-lines
  77.                   # comments and boring pad text
  78.                   xx.yy.zz        THREE
  79.           }
  80.  
  81.           # trailing single line comment
  82.  
  83.      Produces the output:
  84.  
  85.           /*
  86.            * leading block of multi-line comments
  87.            * RCS: $Revision: 2.3 $
  88.            * initialization group
  89.            */
  90.           char *foo[] = {
  91.           #define ONE 0
  92.                   "a.b.c",
  93.           #define TWO 1
  94.                   "d.e.f.g",
  95.           /*
  96.            * embedded block of multi-lines
  97.            * comments and boring pad text
  98.            */
  99.           #define THREE 2
  100.                   "xx.yy.zz",
  101.  
  102.           };
  103.  
  104.  
  105.           /* trailing single line comment */
  106.  
  107. EEEEXXXXAAAAMMMMPPPPLLLLEEEE
  108.      For brevity we have removed the error handling code, and assumed the
  109.      chosen metrics do not have multiple values.
  110.  
  111.      The input file
  112.  
  113.           mystats {
  114.               irix.kernel.percpu.cpu.idle     IDLE
  115.               irix.kernel.percpu.cpu.sys      SYS
  116.               irix.kernel.percpu.cpu.user     USER
  117.               hinv.ncpu                       NCPU
  118.           }
  119.  
  120.      produces the following C code, suitable for ####iiiinnnncccclllluuuuddddeeee-ing
  121.  
  122.           /*
  123.            * Performance Metrics Name Space Map
  124.            * Built by pmgenmap from the file
  125.            * mystats.metrics
  126.  
  127.  
  128.  
  129.                                                                         PPPPaaaaggggeeee 2222
  130.  
  131.  
  132.  
  133.  
  134.  
  135.  
  136. PPPPMMMMGGGGEEEENNNNMMMMAAAAPPPP((((1111))))                                                        PPPPMMMMGGGGEEEENNNNMMMMAAAAPPPP((((1111))))
  137.  
  138.  
  139.  
  140.            * on Wed Dec 28 19:44:17 EST 1994
  141.            *
  142.            * Do not edit this file!
  143.            */
  144.  
  145.           char *mystats[] = {
  146.           #define IDLE    0
  147.                   "irix.kernel.percpu.cpu.idle",
  148.           #define SYS     1
  149.                   "irix.kernel.percpu.cpu.sys",
  150.           #define USER    2
  151.                   "irix.kernel.percpu.cpu.user",
  152.           #define NCPU    3
  153.                   "hinv.ncpu",
  154.  
  155.           };
  156.  
  157.      Using the code generated by ppppmmmmggggeeeennnnmmmmaaaapppp, we are now able to easily obtain
  158.      metrics from the Performance Metrics Collection Subsystem (PMCS) as
  159.      follows:
  160.  
  161.  
  162.           #define MAX_PMID 4
  163.  
  164.               int         trip = 0;
  165.               int         numpmid = sizeof(mystats)/sizeof(mystats[0]);
  166.               double      duration;
  167.               pmResult    *resp;
  168.               pmResult    *prev;
  169.               pmID        pmidlist[MAX_PMID];
  170.  
  171.               pmLoadNameSpace(PM_NS_DEFAULT);
  172.               pmLookupName(numpmid, mystats, pmidlist);
  173.               pmFetch(numpmid, pmidlist, &resp);
  174.  
  175.               printf("%d CPUs: %d usr   %d sys   %d   idle0,
  176.                      resp->vset[NCPU]->vlist[0].value.lval,
  177.                      resp->vset[USER]->vlist[0].value.lval,
  178.                      resp->vset[SYS]->vlist[0].value.lval,
  179.                      resp->vset[IDLE]->vlist[0].value.lval);
  180.  
  181.      Some calls to ensure portability have been removed from the code above
  182.      for the sake of clarity - the example above should not be used as a
  183.      template for programming.  In particular, the raw values of the metrics
  184.      were used when ppppmmmmLLLLooooooookkkkuuuuppppDDDDeeeesssscccc(3) should have been called to determine the
  185.      semantics of each metric.
  186.  
  187.      More complete examples that demonstrate the use of ppppmmmmggggeeeennnnmmmmaaaapppp and may be
  188.      used as a basis for program development are included in the PCP demos,
  189.      e.g.  /_v_a_r/_p_c_p/_d_e_m_o_s/_p_m_c_l_i_e_n_t.
  190.  
  191.  
  192.  
  193.  
  194.  
  195.                                                                         PPPPaaaaggggeeee 3333
  196.  
  197.  
  198.  
  199.  
  200.  
  201.  
  202. PPPPMMMMGGGGEEEENNNNMMMMAAAAPPPP((((1111))))                                                        PPPPMMMMGGGGEEEENNNNMMMMAAAAPPPP((((1111))))
  203.  
  204.  
  205.  
  206. FFFFIIIILLLLEEEESSSS
  207.      ////vvvvaaaarrrr////ppppccccpppp////ppppmmmmnnnnssss////*         default PMNS specification files
  208.  
  209. SSSSEEEEEEEE AAAALLLLSSSSOOOO
  210.      ccccpppppppp(1), PPPPMMMMAAAAPPPPIIII(3), ppppmmmmFFFFeeeettttcccchhhh(3), ppppmmmmLLLLooooaaaaddddNNNNaaaammmmeeeeSSSSppppaaaacccceeee(3), ppppmmmmLLLLooooooookkkkuuuuppppNNNNaaaammmmeeee(3) and
  211.      ppppmmmmnnnnssss(4).
  212.  
  213.  
  214.  
  215.  
  216.  
  217.  
  218.  
  219.  
  220.  
  221.  
  222.  
  223.  
  224.  
  225.  
  226.  
  227.  
  228.  
  229.  
  230.  
  231.  
  232.  
  233.  
  234.  
  235.  
  236.  
  237.  
  238.  
  239.  
  240.  
  241.  
  242.  
  243.  
  244.  
  245.  
  246.  
  247.  
  248.  
  249.  
  250.  
  251.  
  252.  
  253.  
  254.  
  255.  
  256.  
  257.  
  258.  
  259.  
  260.  
  261.                                                                         PPPPaaaaggggeeee 4444
  262.  
  263.  
  264.  
  265.